CREATE  TABLE `crawlers` (
  `crawlerId` INT NOT NULL ,
  `title` VARCHAR(45) NOT NULL ,
  `categoriesCount` INT NOT NULL DEFAULT 0 ,
  `productsCount` INT NOT NULL DEFAULT 0 ,
  `webSiteInfo` TEXT NULL ,
  `status` VARCHAR(45) NOT NULL DEFAULT 'Stopped' ,
  PRIMARY KEY (`crawlerId`) ,
  UNIQUE INDEX `title_UNIQUE` (`title` ASC) );

  ALTER TABLE `crawlers` CHANGE COLUMN `crawlerId` `crawlerId` INT(11) NOT NULL AUTO_INCREMENT  ;
ALTER TABLE `crawlers` ADD COLUMN `updatedDate` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP  AFTER `status` ;
ALTER TABLE `crawlers` ADD COLUMN `productIndex` INT NULL DEFAULT 0  AFTER `updatedDate` ;

CREATE  TABLE `image_duplicates` (
  `id` INT NOT NULL ,
  `originalId` INT NOT NULL ,
  `duplicateId` INT NOT NULL ,
  `isNew` BIT NOT NULL DEFAULT 1 ,
  PRIMARY KEY (`id`) );

  ALTER TABLE `image_duplicates` CHANGE COLUMN `id` `id` INT(11) NOT NULL AUTO_INCREMENT;

  ALTER TABLE `crawlers` ADD COLUMN `imageName` VARCHAR(115) NULL  AFTER `productIndex` ;
UPDATE `crawlers` SET `imageName`='slami.png' WHERE `crawlerId`='1';
UPDATE `crawlers` SET `imageName`='muztorg.png' WHERE `crawlerId`='2';
UPDATE `crawlers` SET `imageName`='invask.png' WHERE `crawlerId`='3';

ALTER TABLE `dbs`.`products` ADD COLUMN `archived` BIT NULL DEFAULT 0  AFTER `createdByUser`;

ALTER TABLE `dbs`.`category_images`
  ADD CONSTRAINT `imageId`
  FOREIGN KEY (`imageId` )
  REFERENCES `dbs`.`images` (`imageId` )
  ON DELETE CASCADE
  ON UPDATE NO ACTION
, ADD INDEX `imageId` (`imageId` ASC) ;

ALTER TABLE `dbs`.`orders` ADD COLUMN `statusId` INT NULL DEFAULT 0  AFTER `placeDate` ;

